<?php
	require_once('class/SanPhamDAO.php');
	require_once('class/LoaiSanPhamDAO.php');
	require_once('class/GianHangDAO.php');
	
	//source tên sản phẩm
	$dsSanPham = SanPhamDAO::LayDanhSachSanPham(0);
	$srcSanPham ='[';
	foreach($dsSanPham as $sanPham)
	{
		$srcSanPham .= '"'.$sanPham->TenSanPham.'",';
	}
	$srcSanPham .=']';
	
	//source tên loại sản phẩm
	$dsLoaiSanPham = LoaiSanPhamDAO::LayDanhSachTatCaLoaiSanPham();
	$srcLoaiSP ='[';
	foreach($dsLoaiSanPham as $loaiSanPham)
	{
		$srcLoaiSP .= '"'.$loaiSanPham->TenLoaiSP.'",';
	}
	$srcLoaiSP .=']';
	
	//source tên gian hàng
	$dsGianHang = GianHangDAO::LayTatCaGianHangTheoNgayCapNhat(0);
	$srcGianHang ='[';
	foreach($dsGianHang as $gianHang)
	{
		$srcGianHang .= '"'.$gianHang->TenGianHang.'",';
	}
	$srcGianHang .=']';
	
?>
<div class="list-shop-wrapper">
	<div class="navigator">
      <ul >        	
        <li style="float:left;"> 
            	Tìm theo:           
				<input name="radTuyChon" id="radSanPham" type="radio" value="1" checked onClick="funcThayDoi_DoiTuongTimKiem()"> 
                <label for="radSanPham">Sản phẩm</label>
            </li>
            <li style="float:left;">
                <input name="radTuyChon" id="radGianHang" type="radio" value="2" onClick="funcThayDoi_DoiTuongTimKiem()" > 
                <label for="radGianHang">Gian hàng</label>
            </li>           
       </ul>
    </div>
    <!--end .navigator-->
    <div class="list-shop" id="tim_kiem_sp">
    	<div class="text-normal-1">
        <table width="100%" border="0" cellspacing="5" cellpadding="0" style="margin:5px; border:2px solid #F3F3F3;">
          <tr>
            <td align="right"><label for="txtTenGianHang_GH">Tên sản phẩm:</label></td>
            <td>
            	<input name="txtTenSanPham" type="text" id="txtTenSanPham" size="20" maxlength="100">			
                <script>
					$(function(){
						$( "#txtTenSanPham" ).autocomplete(
							{source: <?php echo $srcSanPham; ?>},
							{ delay: 0 }
						);
					});
				</script>              
            </td>
            <td align="right"><label for="txtSlogan">Loại sản phẩm:</label></td>
            <td>
                  <input name="txtLoaiSP" type="text" id="txtLoaiSP" size="15" maxlength="50">
                  <script>
					$(function(){
						$( "#txtLoaiSP" ).autocomplete(
							{source: <?php echo $srcLoaiSP; ?>},
							{ delay: 0 }
							);
					});
				  </script>                      
            </td>
            <td align="right"> <label txtTenGianHang>của gian hàng: </label></td>
            <td>
            	<input name="txtTenGianHang" type="text" id="txtTenGianHang" size="20" maxlength="100">              	 <script>
					$(function(){
						$( "#txtTenGianHang" ).autocomplete(
							{source: <?php echo $srcGianHang; ?>},
							{ delay: 0 }
							);
					});
				  </script>    
            </td>
          </tr>
          <tr>
            <td align="right">
           	  <label for="txtGia_Tu">Giá từ:</label>
            </td>
            <td>
            	<input name="txtGia_Tu" style="text-align:right;" type="text" id="txtGia_Tu" value="0" size="15" maxlength="10"></td>
            <td align="right">
           	  <label for="txtGia_Den">đến:</label>
            </td>
            <td>
            	<input name="txtGia_Den"  style="text-align:right;" type="text" id="txtGia_Den" value="0" size="15" maxlength="15"></td>
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td align="right">
            	<label for="dtpNgayTaoGH_Tu">Ngày đăng từ:</label>
            </td>
            <td>
           		<input name="dtpNgayDangSP_Tu" type="text" id="dtpNgayDangSP_Tu" size="15">
            </td>
            <td align="right"><label for="dtpNgayTaoGH_Den">đến ngày:</label></td>
            <td>
            	<input name="dtpNgayDangSP_Den" type="text" id="dtpNgayDangSP_Den" size="15">
            </td>
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>        
          <tr>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td align="right">
            	<input name="txtTimKiemSP" type="submit" value="Tìm kiếm" class="ui-state-default ui-state-hover" onClick="funcTimKiemSP()" />
            </td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
        </div>
    </div>
    <!--end .list-shop: khung tìm kiếm sản phẩm-->
    <div class="list-shop" id="tim_kiem_gh"  style="display:none;">
    	<div class="text-normal-1">
        <table width="100%" border="0" cellspacing="5" cellpadding="0" style="margin:5px; border:2px solid #F3F3F3;">
          <tr>
            <td width="19%" align="right"><label for="txtTenGianHang_GH">Tên gian hàng:</label></td>
            <td width="29%">
            	<input name="txtTenGianHang_GH" type="text" id="txtTenGianHang_GH" size="35" maxlength="100">              
                <script>
					$(function(){
						$( "#txtTenGianHang_GH" ).autocomplete(
							{source: <?php echo $srcGianHang; ?>},
							{ delay: 0 }
							);
					});
				  </script>   
            </td>
            <td width="12%" align="right">&nbsp;</td>
            <td width="40%" align="left">&nbsp;</td>
          </tr>
          <tr>
            <td align="right">
            	<label for="dtpNgayTaoGH_Tu">Ngày tạo từ:</label>
            </td>
            <td>
           		<input name="dtpNgayTaoGH_Tu" type="text" id="dtpNgayTaoGH_Tu" size="15">
            </td>
            <td align="right"><label for="dtpNgayTaoGH_Den">đến ngày:</label></td>
            <td align="left">
            	<input name="dtpNgayTaoGH_Den" type="text" id="dtpNgayTaoGH_Den" size="15">
            </td>
          </tr>        
          <tr>
            <td colspan="4" align="right">&nbsp;</td>
          </tr>
          <tr>
            <td align="right">&nbsp;</td>
            <td align="right">
            	<input name="txtTimKiemGH" type="submit" value="Tìm kiếm" class="ui-state-default ui-state-hover" id="txtTimKiemGH" onclick="funcTimKiemGH()" />
            </td>
            <td align="right">&nbsp;</td>
            <td align="right">&nbsp;</td>
          </tr>
        </table>
        </div>
    </div>
    <!--end .list-shop: khung tìm kiếm gian hàng-->
    <div id="kq_tim_kiem">
     	
    </div>
    <!--hiển thị kết quả tìm kiếm -->
</div>
<!--end list shop wrapper-->